<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page  import="shcool.dao.*,java.sql.*,school.entity.*"  %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'doLogin.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
  <%
  
  request.setCharacterEncoding("utf-8");
  
int  id=Integer.parseInt(request.getParameter("stuno"));
  
  String pwd=request.getParameter("pass");
  
/* if(id==1&&pwd.equals("123456")){
	//第一种用重定向的方法
	//response.sendRedirect("welcome.jsp?username="+name);
	//第二种用转发
	session.setAttribute("login",id);

	//设置session 过期时间

	session.setMaxInactiveInterval(10);

RequestDispatcher rq= request.getRequestDispatcher("admin.jsp");
	rq.forward(request, response);
	
	
}else{
	
	out.print("用户名密码错误");
response.sendRedirect("login.jsp");
	
}
   */
  
   
   MySqlStudentDaoImpl  stu=new MySqlStudentDaoImpl();  
  
   Student s = stu.login(id, pwd);
   
   
	if (s == null) {
		System.out.println("用户名或密码错误,登录失败!");
		response.sendRedirect("login.jsp");
	} else {
		session.setAttribute("login",id);
		
		RequestDispatcher rq= request.getRequestDispatcher("ViewResults.jsp");
		rq.forward(request, response);
	}
  
  %>
  

  </body>
</html>
